package com.wen40;

import org.apache.ibatis.plugin.Interceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.github.pagehelper.PageHelper;

@Configuration
@ConditionalOnClass({PageHelper.class})
@EnableConfigurationProperties(PageHelperConfiguration.class)
public class MybatisAutoConfigurationPlus {
  @Autowired
  PageHelperConfiguration pageHelperConfiguration;

  @Bean
  public Interceptor[] interceptors() {
    PageHelper pageHelper = new PageHelper();
    pageHelper.setProperties(pageHelperConfiguration.getPageHelper());
    return new Interceptor[] {pageHelper};
  }
}
